<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" 
    xmlns:gd="http://schemas.google.com/g/2005" xmlns:yt="http://gdata.youtube.com/schemas/2007" version="1.0">
    <xsl:template match="/">
        <xsl:param name='i'>application/atom+xml</xsl:param>
        <xsl:variable name="contentText" select="atom:content"/>
        <xsl:variable name="entry_counter" select="count(/atom:feed/atom:entry)"/>
        <videos size="{$entry_counter}">
            <xsl:for-each select="/atom:feed/atom:entry">  
                <xsl:variable name="videoId">
                    <xsl:value-of select="atom:id"/>
                </xsl:variable>
                <video id="{$videoId}">
                    <title>
                        <xsl:value-of select="atom:title"/>
                    </title>
                    <author>
                        <name><xsl:value-of select="atom:author/atom:name"/></name>
                        <url><xsl:value-of select="atom:author/atom:uri"/></url>
                    </author>
                        <recorded>
                            <xsl:value-of select="yt:recorded"/>
                        </recorded>
                        <content>
                            <xsl:value-of select="atom:content"/>
                        </content>
                        <location>
                            <xsl:value-of select="yt:location"/>
                        </location>
                    <categories>
                        <xsl:for-each select="atom:category">
                            <xsl:if test="@label">
                                <category>
                                    <xsl:value-of select="@label"/>
                                </category>
                            </xsl:if>    
                        </xsl:for-each>
                    </categories> 
                    <links>
                        <xsl:for-each select="atom:link">
                            <xsl:if test="@type != $i">
                                <link><xsl:value-of select="@href"/></link>
                            </xsl:if>
                        </xsl:for-each>
                    </links>    
                    <thumbnails>
                        <xsl:for-each select="media:group/media:thumbnail">
                            <thumbnail><xsl:value-of select="@url"/></thumbnail>
                        </xsl:for-each>
                    </thumbnails>
                    <xsl:apply-templates select='media:group/yt:duration' /> 
                </video>    
            </xsl:for-each>   
        </videos>    
    </xsl:template> 
    <xsl:template match="media:group/yt:duration">
        <duration>
            <xsl:value-of select="@seconds"/>seconds
        </duration>
    </xsl:template>
</xsl:stylesheet>
